# -*- coding: UTF-8 -*-
from app import app


class AutoID(object):
    def __init__(self):
        self.db = app.db

    def get_last_insert_id(self):
        session = self.db.session
        session.execute(
            "REPLACE INTO kjdv_sequence (stub) VALUES ('a')", bind=self.db.get_engine(app, 'main')
        )
        last_insert_id = session.execute(
            "SELECT LAST_INSERT_ID()", bind=self.db.get_engine(app, 'main')
        ).fetchone()
        return last_insert_id[0]
